// Google test includes
#include <gtest/gtest.h>
#include <gmock/gmock.h>

// Tested file
#include "Parsers/NodeStack.h"

// Mocks and fakes
#include "MockNode.h"

using namespace testing;

TEST(NodeStackTest, EmptyByDefault)
{
	NodeStack<TestNode> stack(1);

	EXPECT_TRUE(stack.empty());
}

TEST(NodeStackTest, NotEmpty)
{
	NodeStack<TestNode> stack(1);

	StrictMock<TestNodeAtom> node("test");
	stack.push(&node);
	EXPECT_FALSE(stack.empty());
}

TEST(NodeStackTest, PushPop)
{
	NodeStack<TestNode> stack(1);

	StrictMock<TestNodeAtom> node("test");
	EXPECT_NO_THROW(stack.push(&node));
	EXPECT_EQ(&node, stack.pop());
	EXPECT_TRUE(stack.empty());
}

TEST(NodeStackTest, PopFromEmpty)
{
	NodeStack<TestNode> stack(1);
	EXPECT_THROW(stack.pop(), std::runtime_error);
}

TEST(NodeStackTest, PushOverflow)
{
	NodeStack<TestNode> stack(1);

	StrictMock<TestNodeAtom> node("test");
	stack.push(&node);
	EXPECT_THROW(stack.push(&node), std::runtime_error);
}
